﻿<%@ Page Language="C#" MasterPageFile="~/Search/MasterPage.master" AutoEventWireup="true" CodeFile="Apply.aspx.cs" Inherits="Search_Scores_Apply" Title="无标题页" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
        var template = '<span style="color:{0};">{1}</span>';

        var Shenhe = function (value) {
            if(value==0){return String.format(template,'red', '未审');}
            if(value==1){return String.format(template,'green', '批准');}
            if(value==2){return String.format(template,'blue', '禁止');}
        }
    </script>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CXDB %>" 
        
        SelectCommand="SELECT ID, BossNod, BossTime, CompanyName, CompanyID, ElectricName, Reason, TradeName, Scores_now, username, DeptName FROM vw_apply_scores WHERE (BossNod &lt;&gt; @BossNod) GROUP BY ID, BossTime, CompanyName, CompanyID, ElectricName, Reason, TradeName, Scores_now, username, DeptName, inTime, BossNod ORDER BY inTime DESC">
        <SelectParameters>
            <asp:Parameter DefaultValue="2" Name="BossNod" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <ext:Store ID="Store1" DataSourceID="SqlDataSource1" runat="server">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="ID"></ext:RecordField>
                    <ext:RecordField Name="CompanyID"></ext:RecordField>                    
                    <ext:RecordField Name="CompanyName"></ext:RecordField>
                    <ext:RecordField Name="ElectricName"></ext:RecordField>
                    <ext:RecordField Name="TradeName"></ext:RecordField>
                    <ext:RecordField Name="Scores_now"></ext:RecordField>
                    <ext:RecordField Name="username"></ext:RecordField>
                    <ext:RecordField Name="DeptName"></ext:RecordField>
                    <ext:RecordField Name="BossNod"></ext:RecordField> 
                    <ext:RecordField Name="Reason"></ext:RecordField> 
                    
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:GridPanel ID="GridPanel1" AutoHeight="true" AutoWidth="true" StoreID="Store1" runat="server">
    <ColumnModel>
        <Columns>
            <ext:Column DataIndex="ID" Header="编号"></ext:Column>
            <ext:Column DataIndex="CompanyID" Header="户号"></ext:Column>
            <ext:Column DataIndex="CompanyName" Header="客户名称"></ext:Column>
            <ext:Column DataIndex="ElectricName" Header="用电类别"></ext:Column>
            <ext:Column DataIndex="TradeName" Header="行业类别"></ext:Column>
            <ext:Column DataIndex="Scores_now" Header="信誉分数"></ext:Column> 
            <ext:Column DataIndex="username" Header="申请人"></ext:Column>
            <ext:Column DataIndex="DeptName" Header="申请人部门"></ext:Column>
            <ext:Column DataIndex="BossNod" Header="审批">
            <Renderer Fn="Shenhe" />
            </ext:Column>
            <ext:CommandColumn Width="180" ColumnID="AllowToShow">
                <Commands>
                <ext:GridCommand Icon="DoorOpen" Text="详细" CommandName="detailshow">
                    <ToolTip Title="详细" />
                    </ext:GridCommand>
                    <ext:GridCommand Icon="ApplicationOsxGo" Text="批准" CommandName="allow">
                    <ToolTip Title="批准" />
                    </ext:GridCommand>
                    <ext:GridCommand Icon="ApplicationOsxError" Text="禁止" CommandName="unallow">
                    <ToolTip Title="禁止" />
                    </ext:GridCommand>
                </Commands>
            </ext:CommandColumn>
        </Columns>
    </ColumnModel>
    <BottomBar>
        <ext:PagingToolBar 
            ID="PagingToolBar1" 
            runat="server" 
            PageSize="10" 
            StoreID="Store1" 
            />
    </BottomBar>
     <AjaxEvents>
        <Command OnEvent="Allow">
            <ExtraParams>
                <ext:Parameter Mode="Raw" Name="id" Value="record.data.ID"></ext:Parameter>
                <ext:Parameter Mode="Raw" Name="reason" Value="record.data.Reason"></ext:Parameter>
                <ext:Parameter Mode="Raw" Name="cmd" Value="command"></ext:Parameter>
            </ExtraParams>
        </Command>
    </AjaxEvents>
    </ext:GridPanel>
</asp:Content>

